package cn.ad.server.web.spring.service.components.http.client;

import java.io.IOException;

/**
 * http Executor
 * @author wangwei
 *
 */
public interface AdHttpExecutor {
	
	/**
	 * HANDLER 执行错误码
	 */
	static final int HANDLER_ERROR_CODE = 911;
	/**
	 * io 执行错误码
	 */
	static final int OI_ERROR_CODE = 912;
	
	/**
	 * 执行get请求
	 * @param adHttpGetRequest
	 * @return
	 */
	AdHttpResponse<?> execute(AdHttpGetRequest adHttpGetRequest) throws ResponseHandleException, IOException;
	
	/**
	 * 执行post请求
	 * @param adHttpPostRequest
	 * @return
	 */
	AdHttpResponse<?> execute(AdHttpPostRequest adHttpPostRequest) throws ResponseHandleException, IOException;
	
	/**
	 * 执行post请求.处理响应
	 * @param adHttpPostRequest
	 * @param responseHandler
	 * @return
	 */
	<T> AdHttpResponse<T> execute(AdHttpGetRequest adHttpGetRequest, final AdResponseHandler<? extends T> responseHandler) throws ResponseHandleException, IOException;
	
	/**
	 * 执行get请求.处理响应
	 * @param adHttpPostRequest
	 * @param responseHandler
	 * @return
	 */
	<T> AdHttpResponse<T> execute(AdHttpPostRequest adHttpPostRequest, final AdResponseHandler<? extends T> responseHandler) throws ResponseHandleException, IOException;
	
}
